/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import moment from "moment";
import service from "../utils/request";
import { ResultEntity } from "./result-entity";

export interface User {
  id?: number;
  username: string;
  password: string;
  regTime?: moment.Moment;
}

export function getUserList() {
  return service.get<ResultEntity<User[]>>("/user/list");
}

export function getUser(id: number) {
  return service.get<ResultEntity<User>>(`/user/get/${id}`);
}

export function saveOrUpdateUser(user: User) {
  return service.post<ResultEntity<User>>(`/user/saveOrUpdate`, user);
}

export function deleteUser(id: number) {
  return service.post<ResultEntity<void>>(`/user/delete/${id}`);
}
